package menu

import (
	"context"

	v1 "gitee.com/liangziyisheng/caas-platform-mc/api/menu/v1"
	"gitee.com/liangziyisheng/caas-platform-mc/internal/consts"
	"gitee.com/liangziyisheng/caas-platform-mc/internal/service"
)

func (c *ControllerV1) Apps(ctx context.Context, req *v1.AppsReq) (res *v1.AppsRes, err error) {

	out, err := service.Menu().ListApp(ctx)
	if err != nil {
		return nil, err
	}
	res = &v1.AppsRes{Data: make([]consts.DdicInfo1, 0)}
	for _, v := range out.Data {
		t := consts.DdicInfo1{
			Value: v.AppCode,
			Label: v.Description,
		}
		res.Data = append(res.Data, t)
	}
	return res, nil
}
